package com.ruoyi;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.Inet4Address;
import java.net.InetAddress;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.UnknownHostException;
/**
 * 启动程序
 *
 * @author ruoyi
 */
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
//@MapperScan("com.ruoyi.**.mapper")
public class RuoYiApplication
{
    public final static Logger log = LoggerFactory.getLogger(RuoYiApplication.class);
    public static void main(String[] args) throws UnknownHostException
    {
        // System.setProperty("spring.devtools.restart.enabled", "false");
        ConfigurableApplicationContext application = SpringApplication.run(RuoYiApplication.class, args);
        Environment env = application.getEnvironment();
        //String ip = InetAddress.getLocalHost().getHostAddress();
        InetAddress[] allByName = InetAddress.getAllByName(InetAddress.getLocalHost().getHostName());

        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path");

        log.info("\n----------------------------------------------------------\n\t" +
                "Application  is running! Access URLs:\n\t" +
                "Local: \t\thttp://localhost:" + port + path + "\n\t" );

        for (InetAddress inetAddress : allByName) {
            if (inetAddress instanceof Inet4Address) {
                log.info( "External: \thttp://" + inetAddress.getHostAddress() + ":" + port + path + "\t"  );
            }
        }

        log.info( "----------------------------------------------------------");
    }
}
